package elcs.member.model;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import elcs.board.model.BoardVO;

@Repository
public class MemberDaoImpl  implements MemberDao{
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public MemberVO findMemberByIdAndPassword(MemberVO mvo) {
		// TODO Auto-generated method stub
		System.out.println("findMemberByIdAndPassword"+mvo);
		return sqlSessionTemplate.selectOne("member.findMemberByIdAndPassword",mvo);
	}

	@Override
	public MemberVO findMemberById(String id) {
		// TODO Auto-generated method stub
		System.out.println(id);
		MemberVO mvo=sqlSessionTemplate.selectOne("member.findMemberById",id);
		System.out.println(mvo);
		return mvo;
	}

	@Override
	public MemberVO findMemberByNick(String nick) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("member.findMemberByNick",nick);
	}

	@Override
	public void register(MemberVO mvo) {
		// TODO Auto-generated method stub
		System.out.println(mvo);
		sqlSessionTemplate.insert("member.register",mvo);
		
	}

	@Override
	public List<MemberVO> findAllMember(String pageno) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList("member.findAllMember",pageno);
	}

	@Override
	public Object updateMemberByLevelPoint(MemberVO mvo) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.update("member.updateMemberByLevelPoint", mvo);
	}

	@Override
	public int totalContent() throws Exception {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectOne("member.totalContent");
	}

	@Override
	public List findMemberByLevel(String value) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectList("member.findMemberByLevel",value);
	}

	@Override
	public List findMemberByName(String value) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectList("member.findMemberByName",value);
	}

	@Override
	public List findMemberByAddress(String value) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectList("member.findMemberByAddress",value);
	}

	@Override
	public void updateMemberByLevel(MemberVO mvo) {
		sqlSessionTemplate.update("member.updateMemberByLevel", mvo);
		
	}

	@Override
	public MemberVO findMemberBySsn(int ssn) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectOne("member.findMemberBySsn",ssn);
		
		
	}

	@Override
	public MemberVO findMemberByIdAndSsn(MemberVO mvo) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectOne("member.findMemberByIdAndSsn",mvo);
		
	}

	@Override
	public int updateMemberByPassword(MemberVO mvo) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.update("member.memberUpdateByPassword",mvo);
	}

	@Override
	public void updateMemberByPoint(MemberVO mvo) {
		// TODO Auto-generated method stub
		this.sqlSessionTemplate.update("member.updateMemberByPoint",mvo);
	}
	
	@Override
	public List<MemberVO> mypageMyInfo() {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList("member.mypageMyInfo");
	}

	@Override
	public void mypageUpdate(MemberVO mvo) {
		// TODO Auto-generated method stub
		System.out.println("dao"+mvo);
		sqlSessionTemplate.update("member.mypageUpdate",mvo);
	}

	@Override
	public void mypageDelete(MemberVO mvo) {
		// TODO Auto-generated method stub
		System.out.println("dao"+mvo);
		sqlSessionTemplate.delete("member.mypageDelete",mvo);
	}

	@Override
	public List findRankList() {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList("member.findRankList");
	}

	@Override
	public void updateMemberByGroup(MemberVO mvo) {
		// TODO Auto-generated method stub
		System.out.println("groupupdate "+mvo);
		sqlSessionTemplate.update("member.updateMemberByGroup",mvo);
		
	}

	@Override
	public List findmemberByGroup(String name) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList("member.findmemberByGroup",name);
	}
	
	
	
}
